package com.ruoyi.app.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.domain.dto.AdvertisingSettingDto
import com.ruoyi.app.domain.vo.*
import com.ruoyi.app.service.IndexApiService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("api/index")
@Api(tags = ["首页相关接口"])
class IndexApiController {

    @Autowired
    private lateinit var indexApiService: IndexApiService

    @ApiOperation("获取banner数据")
    @GetMapping("getIndexBannerList")
    fun getIndexBannerList(): Data<List<AdvertisingVo>> = indexApiService.getIndexBannerList()

    @ApiOperation("获取广告配置参数")
    @GetMapping("getAdvertisingSetting")
    fun getAdvertisingSetting(advertisingSettingDto: AdvertisingSettingDto): Data<AdvertisingSettingVo> =
        indexApiService.getAdvertisingSetting(advertisingSettingDto)

    @ApiOperation("获取全局参数配置")
    @GetMapping("getGlobalSetting")
    fun getGlobalSetting(): Data<GlobalSetting> = indexApiService.getGlobalSetting()

    @ApiOperation("提取短视频")
    @GetMapping("resolveVideo")
    fun resolveVideo(@RequestParam("urlText", required = true) urlText: String): Data<List<VideoVo>> = indexApiService.resolveVideo(urlText)
    @ApiOperation("获取功能菜单数据")
    @GetMapping("getFunctionList")
    fun getFunctionList(): Data<IndexFunction> = indexApiService.getFunctionList()
}